package com.huawei.esdk.uc.device.appserver.callback.convert;

import com.huawei.esdk.platform.common.bean.commu.RestReqMessage;
import com.huawei.esdk.platform.common.config.ConfigManager;
import com.huawei.esdk.uc.device.appserver.bean.NotifyRequest;
import com.huawei.esdk.uc.device.bean.XMLReqMsg;

public class NotifyCapabilityConvert
{
    
    public RestReqMessage getNotificationMode2Rest(boolean register)
    {
        RestReqMessage request = new RestReqMessage();
        request.setHttpMethod("POST");
        
        XMLReqMsg payload = new XMLReqMsg();
        
        // 构建报文体
        NotifyRequest acctRequest = new NotifyRequest();
        
        acctRequest.setOpt(register ? "1" : "0");
        
        String serverUrl = ConfigManager.getInstance().getValue("esdk.callback.service.url");
        if (!serverUrl.endsWith("/"))
        {
        	serverUrl += "/";
        }
        acctRequest.setConferStateURL(serverUrl + ConfigManager.getInstance().getValue("esdk.C03.ctcConferStateURL"));
        acctRequest.setConfInfoURL(serverUrl + ConfigManager.getInstance().getValue("esdk.C03.ctcConfInfoURL"));
        acctRequest.setUserStateURL(serverUrl + ConfigManager.getInstance().getValue("esdk.C03.ctcUserStateURL"));
        
        payload.setBody(acctRequest);
        
        request.setPayload(payload);
        
        return request;
    }
    
}
